package com.woniuxy.amusementparkos.service.lzw.impl;

import com.woniuxy.amusementparkos.entity.lzw.AdjustMoneyInfo;
import com.woniuxy.amusementparkos.dao.lzw.AdjustMoneyInfoDao;
import com.woniuxy.amusementparkos.service.lzw.AdjustMoneyInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AdjustMoneyInfo)表服务实现类
 *
 * @author lizhwen
 * @since 2020-04-24 22:23:20
 */
@Transactional
@Service("adjustMoneyInfoService")
public class AdjustMoneyInfoServiceImpl implements AdjustMoneyInfoService {
    @Resource
    private AdjustMoneyInfoDao adjustMoneyInfoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param adjustId 主键
     * @return 实例对象
     */
    @Override
    public AdjustMoneyInfo getById(Integer adjustId) {
        return this.adjustMoneyInfoDao.getById(adjustId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<AdjustMoneyInfo> listAllByLimit(int offset, int limit) {
        return this.adjustMoneyInfoDao.listAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param adjustMoneyInfo 实例对象
     * @return 实例对象
     */
    @Override
    public AdjustMoneyInfo insert(AdjustMoneyInfo adjustMoneyInfo) {
        this.adjustMoneyInfoDao.insert(adjustMoneyInfo);
        return adjustMoneyInfo;
    }

    /**
     * 修改数据
     *
     * @param adjustMoneyInfo 实例对象
     * @return 实例对象
     */
    @Override
    public AdjustMoneyInfo update(AdjustMoneyInfo adjustMoneyInfo) {
        this.adjustMoneyInfoDao.update(adjustMoneyInfo);
        return this.getById(adjustMoneyInfo.getAdjustId());
    }

    /**
     * 通过主键删除数据
     *
     * @param adjustId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer adjustId) {
        return this.adjustMoneyInfoDao.deleteById(adjustId) > 0;
    }

    /**
     * 查询全部数据
     *
     * @return 全部数据的List
     */
    @Override
    public List<AdjustMoneyInfo> listAll() {
        // null: 这里的参数null，代表查询全部
        return this.adjustMoneyInfoDao.listAll(null);
    }

    @Override
    public Long countAllAdjustMoneyInfo() {
        return this.adjustMoneyInfoDao.countAllAdjustMoneyInfo();
    }
}